<!--
 * @Autor: 黄旗
 * @Date: 2020-07-17 09:00:14
-->
<template>
    <Select
        v-show="params.show ? params.show.show : true"
        v-model="params.value"
        :style="params.style"
        :class="params.class"
        :placeholder="params.placeholder || '请选择'"
        :multiple="params.multiple"
        :disabled="params.disabled"
        :clearable="params.clearable"
        :filterable="params.filterable"
        :filter-by-label="params.filterByLabel"
        :remote="params.remote"
        :remote-method="params.remoteMethod"
        :loading="params.loading"
        :loading-text="params.loadingText"
        :label="params.label"
        :size="params.size"
        :not-found-text="params.notFoundText"
        :label-in-value="params.labelInValue"
        :placement="params.placement"
        :transfer="params.transfer"
        :element-id="params.elementId"
        :transfer-class-name="params.transferClassName"
        :prefix="params.prefix"
        :max-tag-count="params.maxTagCount"
        :max-tag-placeholder="params.maxTagPlaceholder"
        :allow-create="params.allowCreate"
        :capture="params.capture"
        @on-change="$emit('on-change', $event)"
        @on-query-change="$emit('on-query-change', $event)"
        @on-clear="$emit('on-clear', $event)"
    >
        <template v-if="params.Group">
            <OptionGroup
                v-for="it in params.childList"
                :key="params.field && params.field.value ? it[params.field.value] : it.value"
                :label="params.field && params.field.label ? it[params.field.label] : it.label"
            >
                <Option
                    v-for="its in it.children"
                    :key="it.field && it.field.values ? its[it.field.values] : its.value"
                    :value="it.field && it.field.values ? its[it.field.values] : its.value"
                    :label="params.field && params.field.label ? it[params.field.label] : it.label"
                ></Option>
            </OptionGroup>
        </template>
        <template v-if="!params.Group">
            <Option
                v-for="it in params.childList"
                :key="params.field && params.field.value ? it[params.field.value] : it.value"
                :value="params.field && params.field.value ? it[params.field.value] : it.value"
                :label="`${params.field && params.field.label ? it[params.field.label] : it.label}`"
            ></Option>
        </template>
    </Select>
</template>

<script>
    export default {
        props: ['params']
    };
</script>
